package com.wh1200.xmlless.test.dao

import com.wh1200.mybatis.xmlless.XmlLessMapper
import com.wh1200.mybatis.xmlless.annotations.TestCriteria
import com.wh1200.xmlless.test.model.TestModel
import org.apache.ibatis.annotations.Mapper

/**
 *
 * @author wuhao
 * @date 2024/1/22 19:36
 * @since v0.0.0
 * @version 1.0
 */
@Mapper
interface TestModelDAO : XmlLessMapper<TestModel> {

  /**
   * @param model
   * @return
   */
  fun insert(model: TestModel)

  /**
   * @param model
   * @return
   */
  fun update(model: TestModel): Int

  fun saveOrUpdate(model: TestModel): Int

  fun findAll(
      @TestCriteria(
          ifExpression = "type == 1",
          sqlExpression = "name = 'a2'"
      )
      @TestCriteria(
          ifExpression = "type == 2",
          sqlExpression = "name = 'b2222'"
      )
      type: Int
  ): List<TestModel>

}
